Trò chơi trí óc trong JavaScript

1 window.onload = function () {
2     
var seconds = 59;
3     
var appendSeconds = document.getElementById("seconds");
4     
var buttonStart = document.getElementById('button-start');
5     
var buttonStop = document.getElementById('button-stop');
6     
var buttonPlay = document.getElementById('button-play');
7     
var buttonNo = document.getElementById('button-no');
8     
var Interval ;
9
10     buttonStart.onclick = function() {
11         clearInterval(Interval);
12         document.getElementById(
'start-screen').style.display = "none";
13         document.getElementById(
'main-screen').style.display = "block";
14         Interval = setInterval(startTimer,
1000);
15     };
16
17     buttonStop.onclick = function() {
18         clearInterval(Interval);
19         buttonPlay.style.display =
"block";
20         buttonStop.style.display =
"none";
21         document.getElementById(
'wait-screen').style.display = "block";
22     };
23
24     buttonPlay.onclick = function() {
25         clearInterval(Interval);
26         buttonPlay.style.display =
"none";
27         buttonStop.style.display =
"block";
28         document.getElementById(
'wait-screen').style.display = "none";
29         Interval = setInterval(startTimer,
1000);
30     };
31
32     buttonNo.onclick = function() {
33         clearInterval(Interval);
34         buttonPlay.style.display =
"none";
35         buttonStop.style.display =
"block";
36         document.getElementById(
'wait-screen').style.display = "none";
37         Interval = setInterval(startTimer,
1000);
38     };
39
40     function startTimer () {
41         seconds--;
42         
if (seconds <= 9){
43             appendSeconds.innerHTML =
"0" + seconds;
44         }
45         
else{
46             appendSeconds.innerHTML =
"" + seconds;
47         }
48         
if (seconds == 0){
49             seconds =
0;
50             appendSeconds.innerHTML =
"0" + seconds;
51             clearInterval(Interval);
52             document.getElementById(
'main-screen').style.display = "none";
53             document.getElementById(
'end-screen').style.display = "block";
54
55             
var score = 0;
56             
if (score <= count){
57                 document.getElementById(
'best-score').style.display = "block";
58             }
59         }
60     }
61 };
62
63 function video_on() {
64     document.getElementById(
'info').style.display = 'none';
65     document.getElementById(
'ON').style.display = 'none';
66     document.getElementById(
'video').style.display = 'block';
67     document.getElementById(
'OFF').style.display = 'inline-block';
68     document.getElementById(
'video').play();
69 }
70
71 function video_off() {
72     document.getElementById(
'video').style.display = 'none';
73     document.getElementById(
'OFF').style.display = 'none';
74     document.getElementById(
'ON').style.display = 'inline-block';
75     document.getElementById(
'info').style.display = 'block';
76     document.getElementById(
'video').load();
77 }
78
79 function flip_endCard() {
80     document.getElementById(
'main-screen').style.display = "none";
81     document.getElementById(
'wait-screen').style.display = "none";
82     document.getElementById(
'end-screen').style.display = "block";
83 }
84
85 function startRTW() {
86     document.getElementById(
'start-screen').style.display = "none";
87     document.getElementById(
'main-screen').style.display = "block";
88 }
89
90 function pauseRTW() {
91     document.getElementById(
'button-play').style.display = "block";
92     document.getElementById(
'button-stop').style.display = "none";
93     document.getElementById(
'wait-screen').style.display = "block";
94 }
95
96 function playRTW() {
97     document.getElementById(
'button-play').style.display = "none";
98     document.getElementById(
'button-stop').style.display = "block";
99     document.getElementById(
'wait-screen').style.display = "none";
100 }
101
102 function getRandomInt(min, max) {
103     
return Math.floor(Math.random() * (max - min + 1)) + min;
104 }


Gõ tìm kiếm nhanh...